import { queryCurrent } from '@/services/sysLogin';

export default {
    namespace: 'sysUser',
    state: {
        currentUser: {},
    },
    effects: {
        *fetchCurrent(_, { call, put }) {
            const res = yield call(queryCurrent);
            if (res.success) {
                const payload = { ...res.result, avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', }
                yield put({
                    type: 'saveCurrentUser',
                    payload,
                });
            }
        },
    },
    reducers: {
        saveCurrentUser(state, action) {
            return { ...state, currentUser: action.payload || {} };
        },
    },
};;
